<template>
  <div id="app">
    <NavBar :active-index="currentRoute" @select="handleNavSelect" />
    <div class="content-container">
      <router-view />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useRoute } from 'vue-router'
import NavBar from '@/components/NavBar.vue'

export default defineComponent({
  name: 'App',
  components: {
    NavBar
  },
  setup() {
    const route = useRoute()
    
    // 计算当前路由对应的导航项
    const currentRoute = computed(() => {
      const path = route.path
      if (path.startsWith('/hhldb/')) {
        return path.replace('/hhldb/', '')
      }
      return 'home'
    })
    
    // 处理导航选择
    const handleNavSelect = (index: string) => {
      console.log(`Navigation item selected: ${index}`)
    }
    
    return {
      currentRoute,
      handleNavSelect
    }
  }
})
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.content-container {
  flex: 1;
  padding-top: 70px; /* 与导航栏高度相同 */
  overflow-y: auto;
}
</style>
